# 模拟存取款机的自动存取款效果

# 定义一个用于存放账户信息的列表变量
account = [
    {"name": "李明", "id": 6228880206666, "psw": "666666", "balance": 70000},
    {"name": "韩梅", "id": 6228880208888, "psw": "888888", "balance": 100000},
    {"name": "李雷", "id": 6228880209999, "psw": "999999", "balance": 90000}
]

for i in range(len(account)):
    while True:
        # 输出初始界面
        print("=" * 13, "欢迎登陆中国银行存取款系统", "=" * 13)
        print()
        cardid = input("请输入银行卡号：")
        cardpsw = input("请输入密码：")
        #判断输入卡号或密码是否正确
        if int(cardid) == account[i]['id'] and cardpsw == account[i]['psw']:
            while True:
                # 登陆后初始界面
                print("=" * 13, "你好，{}".format(account[i]['name']), "=" * 13)
                print("{0:1}{1:15}{2:15}".format(" ", "1.取钱", "2.存钱"))
                print("{0:1}{1:13}{2:15}".format(" ", "3.查询余额", "4.修改密码"))
                print("{0:1}{1:13}".format(" ", "5.退卡"))
                print("=" * 40)
                key = input("请输入您要服务编号：")
                # 根据键盘输入值显示相应信息
                if key == "1":
                    out_value = input("请输入您需要的取款金额：")
                    if int(out_value) > account[i]['balance']:
                        print("当前账户可用余额不足，请重新输入！")
                        continue
                    account[i]['balance'] = account[i]['balance'] - int(out_value)
                elif key == "2":
                    in_value = input("请输入您需要的存款金额：")
                    account[i]['balance'] = account[i]['balance'] + int(in_value)
                elif key == "3":
                    print("当前账户可用余额为：{}元".format(account[i]['balance']))
                elif key == "4":
                    newpsw = input("请输入新密码：")
                    if len(newpsw) != 6:
                        print("请输入6位数密码！")
                        continue
                    account[i]['psw'] = newpsw
                elif key == "5":
                    print("=" * 13, "再见", "=" * 13)
                    break
                else:
                    print("=============无效的键盘输入！=============")
            break
        else:
            print("-" * 40)
            print()
            print(" " * 4, "您输入的卡号或密码有误，请重新输入！")
            print()
            print("-" * 40)
